﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using YWTSSys.Library;
using System.Data.Common;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Data.Sql;
using YWTSSys.Model;
namespace YWTSSys.DAL
{
    public  class SEMailListDAL
    {
        public static int Add(string MailTo, string Subject, string Body)
        {
            Database DB = DatabaseFactory.CreateDatabase();

            DbCommand dbCommand = DB.GetStoredProcCommand("SEMailList_Add", MailTo, Subject, Body);
            return Convert.ToInt32(DB.ExecuteScalar(dbCommand));
        }
        public static IDataReader GetAllNeedSendList()
	    {
		    Database DB = DatabaseFactory.CreateDatabase();		
		
            DbCommand dbCommand = DB.GetStoredProcCommand("SEMailList_GetAllNeedSendList");
            return DB.ExecuteReader(dbCommand);
	    }
        public static bool UpdateSend(int ID)
        {
            Database DB = DatabaseFactory.CreateDatabase();

            DbCommand dbCommand = DB.GetStoredProcCommand("SEMailList_UpdateSend", ID);
            try
            {
                DB.ExecuteScalar(dbCommand);
                return true;
            }
            catch (Exception exc)
            {
                return false;
            }
        }
    }
}
